/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticketmaster.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.RowSet;
import ticketmaster.dataobject.TicketView;

/**
 *
 * @author Wei Liu
 */
public class TicketViewDAO extends BaseEntityDAO
{
    public Collection<TicketView> getAllTicketViewDO(int customerID)
    {
        String sql = "SELECT * FROM `ticket_master`.`ticketsview` where customerID = " + customerID;
        TicketView ticketView = new TicketView();
        RowSet crs = query(sql);
        Collection<TicketView> ticketViews = new ArrayList<TicketView>();
        try
        {
            while (crs.next())
            {
                TicketView bookedticketDO = (TicketView) this.getObject(crs, ticketView);
                TicketView item = new TicketView();
                item.setBookedDate(bookedticketDO.getBookedDate());
                item.setBookedTicketID(bookedticketDO.getBookedTicketID());
                item.setCustomerID(bookedticketDO.getCustomerID());
                item.setEventDescription(bookedticketDO.getEventDescription());
                item.setEventName(bookedticketDO.getEventName());
                item.setIsCancelled(bookedticketDO.isIsCancelled());
                item.setIsPaid(bookedticketDO.isIsPaid());
                item.setPrice(bookedticketDO.getPrice());
                item.setSeatCategory(bookedticketDO.getSeatCategory());
                item.setSeatNumber(bookedticketDO.getSeatNumber());
                item.setTransactionID(bookedticketDO.getTransactionID());
                item.setVenueName(bookedticketDO.getVenueName());
                item.setEventID(bookedticketDO.getEventID());
                item.setVenueID(bookedticketDO.getVenueID());
                ticketViews.add(item);
            }
        }
        catch (SQLException ex)
        {
            Logger.getLogger(BookedTicketDAO.class.getName()).log(Level.SEVERE, null, ex);
        }

        return ticketViews;
    }
}
